<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.is.util.ParamUtil"%>
<%@page import="java.util.List"%>
<%@page import="com.is.control.StudentControl"%>
<%@page import="com.is.model.Student"%>
<%@page import="com.is.util.DesData"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="/InterStu/resources/image/favicon.ico" />
<link rel="stylesheet" type="text/css" href="resources/css/common.css"/>
<link rel="stylesheet" type="text/css" href="resources/css/student.css"/>
<link href="resources/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="resources/js/jquery-1.8.1.js"></script>
<script type="text/javascript" src="resources/js/jquery.artDialog.js"></script>
<script type="text/javascript" src="resources/js/iframeTools.js"></script>
<script type="text/javascript">
	(function (config) {
	    config['fixed'] = true;
	    config['lock'] = true;
	    config['okVal'] = '确定';
	    config['cancelVal'] = '取消';
		config['skin'] = 'default';
		config['drag'] = 'true';
	    // [more..]
	})(art.dialog.defaults);
	
	$(function(){
		$(".link").click(function(){
			var frameUrl = $(this).attr("title");
			var name = $(this).html();
			$.dialog.open(frameUrl,{width:800,height:'auto',title:name+"同学的查询结果"});
		})
		if($(".content").val() != ""){
			$(".clear").show();
		} else{
			$(".clear").hide();
		}
		$(".clear").click(function(){
			$(".content").val(null).focus();
			$(this).hide();
		})
		$(".content").keyup(function(){
			if($(".content").val() != ""){
				$(".clear").show();
			} else{
				$(".clear").hide();
			}
		})
	})
	
</script>
<title>学生查询页面</title>
</head>
<body>
<%
		DesData des = new DesData();
		String input = ParamUtil.getString(request,"input","");
		//int stuId = Integer.parseInt(des.decrypt(ParamUtil.getString(request,"STUID","4d3d3f222d4c6e08")));
		if(input!=null&&!input.equals("")){
	    	  session.setAttribute("input",input);
		}
       String defaultInput = "请输入您的学号或中文姓名";
       if(session.getAttribute("input")!=null&&!session.getAttribute("input").equals("")){
    	   defaultInput = (String)session.getAttribute("input");
       }
%>
<form action="studentRead.jsp" method="post">
	<p class="key">东北师范大学留学生预科部教学系统--成绩查询</p>
	<p class="container pr">
		<input type="text" name="input"  class="content" value="<%=defaultInput %>" /><span class="pa clear"></span>
		<input type="submit" class="search" value="查询">
	</p>
</form>
<%
      if(input!=null&&!input.equals("")){
    	  %>
    	 <p class="title">符合您输入的关键字的结果有：（点击进入查看该学生的信息）</p> 
    	 <%
    	 List<Integer> stuIds = StudentControl.getStudentIdByKeyword(input);
    	  if(stuIds.size()>0){
    		  for(Integer i:stuIds){
    		      Student s = StudentControl.getStudent(i);
    		      String show = "姓名："+s.getChineseName()+"("+s.getPassportName()+")     国籍:"+s.getNationality()+"("+s.getNationalityEn()+")";
    			  %>
    			  
    		  <p class="result"><a class="link" id="head" href="javascript:void(0);" title="studentResult.jsp?stuId=<%=des.encrypt(String.valueOf(i)) %>"><%=s.getChineseName() %></a><br/>
    		  <%out.print(show.replaceAll(input,"<font color='red'>"+input+"</font>"));%>
    		  </p>
    		  <%
    	  }}else{
    		  out.print(" <p class='result'>抱歉，没有找到符合您输入关键字的结果</p>");
    	  }
      }
%>
</body>
</html>